package panel

import "strings"
import "os"

type Doer interface {
	Do(command string)
}

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func Chop(command string) (fun, arg string) {
	i := strings.IndexRune(command, ' ')
	if i < 0 {
		return command, ""
	}
	return command[0:i], command[i+1:]
}

func WriteOut(lines []string, fname string) error {
	newline := []byte{'\n'}
	of, err := os.Create(fname)
	if err == nil {
		defer of.Close()
		for _, line := range lines {
			// HORRID. Will fix. TODO
			of.WriteString(line)
			of.Write(newline)
		}
	} else {
		Log("oops: ", err)
	}
	return err
}
